import React from 'react'
import Table from '../../../components/Table'
import { connect } from 'react-redux'

const columns = [
  {
    title: '学号',
    dataIndex: 'readerId',
    key: 'readerId',
  },
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
    search: true
  },
  {
    title: '性别',
    dataIndex: 'sex',
    key: 'sex',
    search: true
  },
  {
    title: '生日',
    dataIndex: 'birth',
    key: 'birth',
    search: true
  },
  {
    title: '地址',
    dataIndex: 'address',
    key: 'address',
    search: true
  },
  {
    title: '电话',
    dataIndex: 'telcode',
    key: 'telcode',
  },
  {
    title: 'QQ',
    dataIndex: 'qq',
    key: 'qq',
  },
  {
    title: '微信',
    dataIndex: 'weixin',
    key: 'weixin',
  },

]

class MyBookFriends extends React.PureComponent {
  constructor (props) {
    super(props)

  }

  render () {
    const { tableData } = this.props
    const { height } = this.props
    return (
      <Table
        rowKey={'readerId'}
        columns={columns}
        className={'table-height'}
        scroll={{ y: height ? height - 90 : '' }}
        dataSource={tableData.toJS()}
        pagination={{
          showTotal: (total, range) => `第${range[0]}-${range[1]}条/共${total}条`,
          defaultPageSize: 10,
          showSizeChanger: true,
          pageSizeOptions: [10, 20, 50, 100, 200, 500],
        }}
      />
    )
  }
}

const mapStateToProps = (state) => {
  return {
    tableData: state.get('getMyBookFriendsTableData'),
    height: state.get('getHeight')
  }
}
export default connect(mapStateToProps)(MyBookFriends)